Computer software programs, both object-oriented and non-object-oriented in nature, often accomplish tasks or operations that can be represented hierarchically, i.e., may be represented using a tree structure, with a root node, and descending levels of parent nodes and child nodes, with leaf nodes at the end of a particular branch of the tree structure. Individual nodes of a tree structure may represent individual steps or operations. For example, a computer software program may perform a series of related operations, where a root operation has one or more sub-operations (i.e., child operations), and each child operation may itself have one or more child operations.
FIG. 1 shows a tree structure (10) representing a hierarchical operation, where the tree structure (10) has a root operation (11) and a parent operation (12). The parent operation (12) has two child operations, child operation 1 (14) and child operation 2 (16). Each operation (the root operation (11), the parent operation (12), the child operation 1 (14), and the child operation 2 (16)) may be associated with data gathered or used by the software program, program parameters, commands, instructions, or other information. Often, data is gathered by a particular operation of the software program and is used by child operations. For example, the parent operation (12) may represent a step of a testing procedure that gathers and stores testing data. Child operation 1 (14) and child operation 2 (16) may represent subordinate operations of the testing procedure, which require access to stored data relating to the parent operation (12).
As shown in FIG. 2, another example of a hierarchical operation represented by a tree structure is a management system for a chain of bookstores. For the purpose of this example, the chain of bookstores uses a computer software program to manage aspects of the operations of each bookstore in the chain. A tree structure (30) includes a root node, such as a bookstore operations node (32). The bookstore operations node (32) has two child nodes that represent child operations: bookstore location 1 transactions (34) and bookstore location 2 transactions (36), which represent book purchase transactions at two different bookstore locations.
The operations for bookstore location 1 transactions (34) and bookstore location 2 transactions (36) each has child operations. In fact, bookstore location 1 transactions (34) has two child operations, order 1-1 Anna Karenina (38) (representing a customer purchase of the book Anna Karenina), and order 1-2 Doctor Zhivago (40). Additionally, bookstore location 2 transactions (36) has three child nodes, order 2-1 Crime and Punishment (42), order 2-2 War and Peace (44), and order 2-3 Crime and Punishment (46) (Crime and Punishment was purchased in two separate transactions).
Those skilled in the art will appreciate that the tree structure (30) may encompass other operations than as depicted in FIG. 2. For example, a particular operation representing a book purchase may also have associated child operations representing information or data of interest, such as a purchase total or time of purchase data, etc.
Data associated with the operations of the bookstores may be accessed and displayed for various purposes. For example, a marketing executive may direct a programmer to gather data for the purpose of generating web site sales charts which track total sales per day per bookstore, and the programmer may then write a software program to gather book purchase data from each node representing a book purchase. Next, the programmer determines relationships between individual data elements (e.g., a first data element corresponds to a first book purchase, and a second data element corresponds to a second book purchase). After determining relationships between individual data elements, the programmer may then format data appropriately with a document presentation standard (e.g., mark each data with markup language tags, such as Hypertext Markup Language (HTML) tags, Extensible Markup Language (XML) tags, Postscript tags, etc.) for display on the web site. A web server may then serve up formatted data to a browser. During then execution of a program (e.g., data gathering), several issues of concern may arise, such as avoiding corruption of raw data by overwriting, and access and security of the raw and formatted data elements.
A common concern when designing software programs that involve hierarchical operations, such as the software program associated with the tree structure (30), is the issue of data security. For example, if the software program is used as a library by client code, concerns may exist that data may be corrupted or manipulated by improper code or the use of an unstable network connection. Examples of inappropriate use include using client code to improperly or maliciously access data associated with hierarchical operations. The client code may improperly overwrite data associated with order 1-1 Anna Karenina (38) when storing data associated with order 2-1 Crime and Punishment (42). Alternatively, credit card data associated with the order may be maliciously obtained. In addition, client code may improperly override methods of the program. In order to prevent such inappropriate use, a variety of programming techniques and/or constructs may be used in designing the program in order to enhance the robustness and security of the program.
One method to protect data, attributes, and methods of object-oriented software programs is to use access modifiers. An example of an access modifier is the declaration of method or an attribute of a particular class as “private” or “public.” A private method or attribute allows only objects instantiated from the particular class to invoke the method or access the attribute labeled “private.” In contrast, the public method or attribute allows objects of all classes to interact with the method or attribute labeled “public.”
Access modifiers may also be used while declaring classes, and especially useful when declaring inner classes. An inner class is a class declared within another class, as shown in Java™ source code below (ellipses (“ . . . ”) indicate source code not shown):
public class outerClass {private outerClassData;private class innerClass {private privateMethod ( ) {...}...}...}
Referring to the segment of source code, methods declared as the private inner class innerClass are able to access the data of the outerClass class, even if declared “private.” Also, private methods and data of an inner class are accessible from code of an outer class containing the inner class. For example, code in a method of the outerClass class can access the private method privateMethod( ) of the inner class innerClass.